<template>
	<view class="mine">
		<view style="position: relative">
			<image src="@/static/mine/minebg.png" style="width: 100%; height: 450rpx"></image>
			<view class="box1" style="position: absolute; top: 0; width: 100%">
				<u-navbar bgColor="rgba(0,0,0,0)" :fixed="false">
					<view slot="left"></view>
				</u-navbar>
				<view class="align-center" style="padding: 0 32rpx; margin-top: 15rpx">
					<view style="margin-right: 38rpx">
						<image :src="obj.head" style="width: 124rpx; height: 124rpx; border-radius: 50%"></image>
					</view>
					<view class="flex-between1" style="flex: 1">
						<view>
							<view class="align-center" style="margin-bottom: 10rpx">
								<view @click="login"
									style="font-weight: 600; font-size: 48rpx; color: #ffffff; margin-right: 20rpx">


									<text @click="setZiLiao">{{ getUserName(obj.name) }}</text>
								</view>

								<view v-if="obj.userAuth" class="flex-center1"
									style="font-size: 24rpx; width: 100rpx; height: 40rpx; background: #ffffff; border-radius: 8rpx; border: 1rpx solid #fe4343; color: #fe4343">
									已实名
								</view>
							</view>
							<view style="font-weight: 400; font-size: 28rpx; color: #ffffff">
								<text v-if="obj.sex == 0">女</text>
								<text v-if="obj.sex == 1">男</text>
								<text v-if="obj.age">· {{ obj.age}}岁</text>
								<text v-if="obj.phone" @click="setZiLiao">· {{ getPhoneStr(obj.phone) }}</text>


							</view>
						</view>
						<view>
							<!-- <u-icon name="arrow-right" color="#fff" size="40" :bold="true"></u-icon> -->
						</view>
					</view>
				</view>
			</view>
		</view>
		<view style="padding: 0 32rpx; position: relative; top: -100rpx">
			<view style="background: #fff; padding: 40rpx">
				<view @click="checkLogin('./collect')" class="flex-between1"
					style="border-bottom: 1rpx solid #eeeeee; padding-bottom: 30rpx">
					<view class="align-center">
						<image src="@/static/mine/mine1.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">我的收藏</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view>
				<view @click="checkLogin('./vitae')" class="flex-between1"
					style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine2.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">我的简历</view>
					</view>
					<view>
						<!-- <text style="font-weight: 400; font-size: 28rpx; color: #999999">简历完成度62%</text> -->
						<image src="@/static/mine/mineright.png"
							style="width: 16rpx; height: 28rpx; margin-left: 16rpx"></image>
					</view>
				</view>
				<view @click="checkLogin('./mygw')" class="flex-between1"
					style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine3.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">我的岗位报名</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view>
				<view @click="checkLogin('./myzs')" class="flex-between1"
					style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine4.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">我的住宿报名</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view>
				<!-- <view class="flex-between1" style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine5.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx"></image>
						<view style="font-size: 30rpx; color: #333333">我的培训报名</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view> -->
				<!-- <view @click="$tools.navigite('./myjl')" class="flex-between1" style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine6.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx"></image>
						<view style="font-size: 30rpx; color: #333333">平台工作经历</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view> -->
				<!-- <view class="flex-between1" style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine7.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx"></image>
						<view style="font-size: 30rpx; color: #333333">推荐邀请</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view> -->
				<view class="flex-between1" @click="$tools.playphone('18911724966')"
					style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine8.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">联系我们</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view>
				<view @click="checkLogin('./setting')" class="flex-between1"
					style="border-bottom: 1rpx solid #eeeeee; padding: 30rpx 0">
					<view class="align-center">
						<image src="@/static/mine/mine9.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">设置</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view>
				<view @click="checkLogin('./mysf')" class="flex-between1" style="padding-top: 30rpx">
					<view class="align-center">
						<image src="@/static/mine/mine10.png" style="width: 32rpx; height: 28rpx; margin-right: 20rpx">
						</image>
						<view style="font-size: 30rpx; color: #333333">切换身份</view>
					</view>
					<view>
						<image src="@/static/mine/mineright.png" style="width: 16rpx; height: 28rpx"></image>
					</view>
				</view>
			</view>
		</view>
		<Tabbar :value="3" />

	</view>
</template>

<script>
	export default {
		data() {
			return {
				obj: {}
			};
		},
		onLoad() {
			this.init();
		},
		methods: {
			setZiLiao() {
				const token = uni.getStorageSync("token")
				console.log('用户token', token)
				if (token) {
					uni.redirectTo({
						url: '/pages/mine/vitae'
					})
				} else {
					uni.redirectTo({
						url: '/pages/login/login'
					})
				}
			},
			getNickName() {
				uni.getUserProfile({
					desc: '请授权微信昵称',
					success: function(res) {
						console.log("授权微信昵称", res)
					}
				})
			},
			getUserName(nameStr) {
				console.log("用户名:", nameStr)
				if (nameStr && nameStr.length < 20) {
					return nameStr
				} else {
					return '设置姓名'
				}
			},
			login() {
				const token = uni.getStorageSync("token")
				console.log('用户token', token)
				if (token) {
					console.log('已经登录成功')

				} else {
					uni.redirectTo({
						url: '/pages/login/login'
					})
				}
			},
			// 检查登录
			checkLogin(pathUrl) {
				const token = uni.getStorageSync("token")
				if (token) {
					this.$tools.navigite(pathUrl)
				} else {
					uni.redirectTo({
						url: '/pages/login/login'
					})
				}
			},

			getPhoneStr(phone) {
				console.log('手机号', phone)
				if (phone) {
					if (phone.length > 11) {
						console.log('手机号长度大于11')
						return '设置手机号'
					}
					console.log('手机号长度', phone.length)
					return phone.slice(0, 3) + "****" + phone.slice(7);
				} else {
					return '设置手机号'
				}


			},
			init() {
				this.$request('front/user/userInfo').then((res) => {
					console.log(res, '获取用户信息成功');
					this.obj = res.obj.userInfo;
				});
			}
		}
	};
</script>

<style lang="less" scoped>
	.mine {
		min-height: 100vh;
		background-color: #f5f6fa;

		.box1 {}
	}

	.nicheng {
		height: 50rpx;
		color: #fff;
	}

	.nicheng::-webkit-input-placeholder {
		color: #fff;
	}
</style>